package ministock;


public class Subscription {
	
	private String statusId;
	
	private String stockName;
	
	public Subscription(String statusId, String stockName) {
		this.statusId = statusId;
		this.stockName = stockName;
	}

	public String getStatusId() {
		return statusId;
	}

	public void setStatusId(String statusId) {
		this.statusId = statusId;
	}

	public String getStockName() {
		return stockName;
	}

	public void setStockName(String stockName) {
		this.stockName = stockName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((statusId == null) ? 0 : statusId.hashCode());
		result = prime * result
				+ ((stockName == null) ? 0 : stockName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Subscription other = (Subscription) obj;
		if (statusId == null) {
			if (other.statusId != null)
				return false;
		} else if (!statusId.equals(other.statusId))
			return false;
		if (stockName == null) {
			if (other.stockName != null)
				return false;
		} else if (!stockName.equals(other.stockName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return statusId + "|" + stockName;
	}
	
	public static void main(String[] args) {
		Subscription subscription = Subscription.valueOf("3551147625|sz000002");
		System.out.println(subscription.getStatusId());
		System.out.println(subscription.getStockName());
	}
	
	public static Subscription valueOf(String value) {
		int i = value.indexOf('|');
		return new Subscription(value.substring(0, i), value.substring(i + 1));
	}
}
